<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">

        .main {
            margin: 0;
            padding: 0;
            width: 300px;
            height: 300px;
            background: #ff0076;
            top: 50%;
            left: 50%;
            position: absolute;
            /* 该属性控制元素2D偏移 */
            transform: translate(-50%, -50%);
            display: table;
        }

        .content {
            display: table-cell;
            text-align: center;
            /* 该属性只有在table布局中才会生效 */
            vertical-align: middle;
            padding: 20px;
        }

    </style>
</head>
<body>
<div class="main">
    <div class="content">
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljhdskfhd
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljhdskfhdskf
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljhdskfhdskfhds
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljhdskfhdskf
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljhdskfhd
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljhdsk
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkfljh
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjhfsdkf
        lkdfhsdkfjhsdkflhdsflkdsjhfdskjh
    </div>
</div>
</body>
</html>